module.exports = function(app,entitys,loginRouter,db){
  //用户详情
  app.get('/sheshi',loginRouter, async (req, res) => {
    res.send(await entitys.sheshi.getById(req.query.id))
  })
  //用户列表分页查询
  app.get('/sheshi/list',loginRouter, async (req, res) => {
    let key = req.query.key || '' //按昵称、姓名关键字查询
    res.send(await entitys.sheshi.selectPage(
      `select * from sheshi where id like "%${key}%"`,
      req.query.pageNum,
      req.query.pageSize
    ))
  })
  //用户新增
  app.post('/sheshi',loginRouter, async (req, res) => {
    res.send(await entitys.sheshi.insert(req.body))
  })
  //用户修改
  app.put('/sheshi',loginRouter, async (req, res) => {
    res.send(await entitys.sheshi.updateById(req.body))
  })
  //用户删除
  app.delete('/sheshi',loginRouter, async (req, res) => {
    res.send(await entitys.shehsi.deleteById(req.query.id))
  })
}